package com.ynny.entity;

import com.ynny.dao.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

@Component
public class StudentDaoImpl implements StudentDao{
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Override
    public Student selectStudent(Integer number) {
        String sql = "select * from student_db where number = ?";
        Student student =jdbcTemplate.queryForObject(sql,new BeanPropertyRowMapper<Student>(Student.class));
        return student;

    }

    @Override
    public int updateStudent(Student student) {
        String sql = "update student_db set name = ?,sex = ?,grade = ?,clazz = ? where number = ?";
        int i = jdbcTemplate.update(sql,student.getName(),student.getSex(),student.getGrade(),student.getClazz(),student.getNumber());
        return i;
    }

    @Override
    public void updateByName(String 张三, String number, String 大一, String 计算机101, String 女) {

    }

    @Override
    public boolean FindAll() {
        return false;
    }

    @Override
    public boolean FindByNumber(String number) {
        return false;
    }
}
